package com.zm.demo.sentinel.client.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zoum
 * @create 2019/5/7 11:24
 */
@RestController
public class UserController {

    @SentinelResource(value = "getUserInfo", fallback="getUserInfoFallback", fallbackClass = {UserControllerFallback.class})
    @RequestMapping
    public JSONObject getUserInfo(Integer id) throws InterruptedException{
//        Thread.sleep(2000L);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("id", id);
        jsonObject.put("name", "zm");
        jsonObject.put("age", "20");
        return jsonObject;
    }
}
